package ginRoute

import (
	"github.com/gin-gonic/gin"
	"net/http"
)

func GinHandler(h http.HandlerFunc) gin.HandlerFunc {
	return func(ctx *gin.Context) {
		h(ctx.Writer, ctx.Request)
	}
}
func GinToHandler(ctx *gin.Context) http.HandlerFunc {
	return func(w http.ResponseWriter, r *http.Request) {
		w = ctx.Writer
		r = ctx.Request
	}
	//return ctx.Writer, ctx.Request
}

type IRouterInit interface {
	InitRouter(group *gin.RouterGroup)
}
type RouterInits []IRouterInit

func NewRouterInits(routes ...IRouterInit) RouterInits {
	return routes
}

func HandleRouterInit(group *gin.RouterGroup, vs ...IRouterInit) {
	for _, ok := range vs {
		ok.InitRouter(group)
	}
}
func NewRouters(router ...IRouterInit) []IRouterInit {

	return router
}
